
object work1 {
  def main(args: Array[String]) {
    def log(message: String): Unit = println(s"Log: $message")

    class Calculator {
      def add(x: Int, y: Int): Int = {
        val result = x + y
        log(s"加法结果是: $result")
        result
      }

      def subtract(x: Int, y: Int): Int = {
        val result = x - y
        log(s"减法结果是: $result")
        result
      }
    }

    val a = new Calculator()
    val result1 = a.add(10, 5)
    val result2 = a.subtract(10, 5)
  }
}